<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ParserConfigSchema"
		targetNamespace="http://www.cycle99.com/tools/ecmadoc"
		elementFormDefault="qualified"
		xmlns="http://www.cycle99.com/tools/ecmadoc"
		xmlns:c="http://www.cycle99.com/tools/ecmadoc"
		xmlns:xs="http://www.w3.org/2001/XMLSchema">
		
	<xs:element name="parser" type="c:ParserConfigGlobal"/>

	<xs:complexType name="ParserConfigGlobal">
		<xs:sequence>
			<xs:element name="tokens" minOccurs="1" maxOccurs="1">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="token" type="ParserToken" minOccurs="0" maxOccurs="unbounded"/>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="modes" minOccurs="1" maxOccurs="1">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="mode" type="ParseMode" minOccurs="0" maxOccurs="unbounded"/>
					</xs:sequence>
				</xs:complexType>
				<xs:unique name="uniqueMode">
					<xs:selector xpath="mode"/>
					<xs:field xpath="@name"/>
				</xs:unique>
			</xs:element>
			<xs:element name="expressions" minOccurs="1" maxOccurs="1">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="expression" type="ParseExpression" minOccurs="0" maxOccurs="unbounded"/>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="format" type="FormatStrings" minOccurs="1" maxOccurs="1"/>
			<xs:element name="types" type="ExternalTypes" minOccurs="0" maxOccurs="1"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="ParserConfigProject">
		<xs:sequence>
			<xs:element name="tokens" minOccurs="0" maxOccurs="1">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="token" type="ParserToken" minOccurs="0" maxOccurs="unbounded"/>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="modes" minOccurs="0" maxOccurs="1">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="mode" type="ParseMode" minOccurs="0" maxOccurs="unbounded"/>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="expressions" minOccurs="0" maxOccurs="1">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="expression" type="ParseExpression" minOccurs="0" maxOccurs="unbounded"/>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			<xs:element name="format" type="FormatStrings" minOccurs="0" maxOccurs="1"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="ParserToken">
		<xs:attribute name="name" type="xs:string" use="required"/>
		<xs:attribute name="handler" type="xs:string" use="required"/>
		<xs:attribute name="value" type="xs:string" use="optional"/>
		<xs:attribute name="match" type="xs:string" use="optional"/>
	</xs:complexType>

	<xs:complexType name="ParseMode">
		<xs:attribute name="name" use="required">
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="Global"/>
					<xs:enumeration value="Function"/>
					<xs:enumeration value="Constructor"/>
					<xs:enumeration value="Literal"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="order" type="xs:string" use="required"/>
	</xs:complexType>

	<xs:complexType name="ParseExpression">
		<xs:sequence>
			<xs:element name="rxp" minOccurs="1" maxOccurs="1">
				<xs:simpleType id="RegularExpressionText">
					<xs:restriction base="xs:string"/>
				</xs:simpleType>
			</xs:element>
		</xs:sequence>
		<xs:attribute name="name" type="xs:string" use="required"/>
		<xs:attribute name="handler" type="xs:string" use="required"/>
		<xs:attribute name="description" type="xs:string" use="optional"/>
	</xs:complexType>
	
	<xs:complexType name="FormatStrings">
		<xs:all minOccurs="1" maxOccurs="1">
			<xs:element name="ConstructorSynopsis" type="SimpleElement" minOccurs="1" maxOccurs="1"/>
			<xs:element name="FunctionSynopsisFull" type="SimpleElement" minOccurs="1" maxOccurs="1"/>
			<xs:element name="FunctionSynopsisBase" type="SimpleElement" minOccurs="1" maxOccurs="1"/>
			<xs:element name="ReturnValueFormat" type="SimpleElement" minOccurs="1" maxOccurs="1"/>
			<xs:element name="VariableSynopsis" type="SimpleElement" minOccurs="1" maxOccurs="1"/>
			<xs:element name="VariableSynopsisGlobal" type="SimpleElement" minOccurs="1" maxOccurs="1"/>
			<xs:element name="PropertySynopsis" type="SimpleElement" minOccurs="1" maxOccurs="1"/>
			<xs:element name="ArgumentFormat" type="SimpleElement" minOccurs="1" maxOccurs="1"/>
			<xs:element name="CommaFormat" type="SimpleElement" minOccurs="1" maxOccurs="1"/>
			<xs:element name="LinkFormat" type="SimpleElement" minOccurs="1" maxOccurs="1"/>
		</xs:all>	
	</xs:complexType>

	<xs:complexType name="SimpleElement" mixed="true">
		<xs:simpleContent>
			<xs:extension base="xs:string"/>
		</xs:simpleContent>
	</xs:complexType>

	<xs:complexType name="ExternalTypes">
		<xs:sequence>
			<xs:element name="type" minOccurs="0" maxOccurs="unbounded">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="link" minOccurs="1" maxOccurs="unbounded">
							<xs:complexType mixed="true">
								<xs:attribute name="name" use="optional" default="default"/>
							</xs:complexType>
						</xs:element>
					</xs:sequence>
					<xs:attribute name="name" use="required"/>
					<xs:attribute name="aliases" use="optional"/>
				</xs:complexType>
				<xs:unique name="unique-link-name">
					<xs:selector xpath="c:link"></xs:selector>
					<xs:field xpath="@name"/>
				</xs:unique>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	
</xs:schema>
